package com.ztesoft.web.common.db.dao.mapper;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import com.ztesoft.web.common.db.arg.DmArg;
import com.ztesoft.web.common.db.po.DmPO;

public interface IDmMapper {

	/**
	 * 获取需要恢复数据的目标表名
	 * @param tableName
	 * @return
	 */
	List<DmPO> selectRDTargetTableName(@Param("tableName")String tableName,
			@Param("id")Integer id);
	
	/**
	 * 获取需要恢复数据的数据
	 * 
	 * @param tableName
	 * @return
	 */
	List<DmPO> selectDataForRD(@Param("tableName") String tableName, @Param("id") Integer id,
			@Param("targetTableName") String targetTableName, @Param("limit") Integer limit);

    List<Integer> countByArg(DmArg arg);

    List<DmPO> selectByArg(DmArg arg);

    DmPO selectByPrimaryKey(Long id);

    List<DmPO> selectByArgAndPage(@Param("subTableName")String subTableName,@Param("arg")DmArg arg, RowBounds rowBound);

 	List<DmPO> selectByArgAndSize(@Param("subTableName")String subTableName,@Param("arg")DmArg arg,@Param("limits")int limits);
 
    int insert(DmPO record);

    int insertSelective(DmPO record);

    int insertBatch(@Param("table")String tableName, @Param("list") List<DmPO> records);

    int updateByArgSelective(@Param("record") DmPO record,
            @Param("arg") DmArg arg);

    int updateByArg(@Param("record") DmPO record,
            @Param("arg") DmArg arg);

    int updateByPrimaryKeySelective(DmPO record);

    int updateByPrimaryKey(@Param("tableName")String tableName, @Param("record")DmPO record);
    
    int deleteByArg(@Param("subTableName")String subTableName,@Param("arg")DmArg arg);

    int updateBySctArg(@Param("subTableName")String subTableName,@Param("record") DmPO record,@Param("arg")DmArg arg);
    
    int deleteByPrimaryKey(Long id);
    
    int updateByArgAndSize(@Param("record")DmPO record,@Param("subTableName")String subTableName,@Param("arg")DmArg arg);
    
	int deleteByDetailInfo(@Param("subTableName")String subTableName, @Param("dmTaskId")int dmTaskId);

	List<DmPO> selectByLimit(@Param("table") String table, @Param("taskId") int taskId, @Param("strategyId") int strategyId,
			@Param("state")String state, @Param("limit") Integer limit);

	List<DmPO> selectByLimit_(@Param("table") String table, @Param("taskId") int taskId, @Param("strategyId") int strategyId,
			@Param("state")String state, @Param("start") Integer start,  @Param("limit") Integer limit);
	
	int updateByLimit(@Param("table") String table, @Param("state_")String state_, @Param("stateDate")Date stateDate, @Param("taskId") int taskId, @Param("strategyId") int strategyId,
			@Param("state")String state, @Param("limit") Integer limit, @Param("errDesc")String errDesc);

	int updateByLimit_(@Param("table") String table, @Param("state_")String state_, @Param("stateDate")Date stateDate, @Param("taskId") int taskId, @Param("strategyId") int strategyId,
			@Param("state")String state, @Param("limit") Integer limit, @Param("errDesc")String errDesc);

	/*List<DmPO> qryLeftErrorInfo(@Param("table") String table, @Param("dmTaskId") int dmTaskId,
			@Param("state")String state);*/
	
	List<DmPO> qryLeftErrorInfo(@Param("table") String table, @Param("dmTaskId") int dmTaskId,
			@Param("state")String state);
	
	List<DmPO> qryRightErrorInfo(@Param("table") String table, @Param("dmTaskId") int dmTaskId,
			@Param("state")String state);

}